package com.qianfeng.demo19_springboot.mq;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

@Component
public class MessageListener {

    @Autowired
    private RedisTemplate redisTemplate;


    @JmsListener(destination="session")
    public void msgListener(String token){
        System.out.println("----------更新Session过期时间----------");
        if (redisTemplate.hasKey(token)) {
            Object value = redisTemplate.boundValueOps(token).get();
            redisTemplate.boundValueOps(token).set(value, 30, TimeUnit.MINUTES);
        }
    }
}
